package cate.game.event.master;

import cate.common.table.d.GDGuild;
import cate.game.event.GameEventListener;
import cate.game.role.Role;

public class RoleNameListener implements GameEventListener<RoleNameEvent> {

    @Override
    public void onEvent(RoleNameEvent gameEvent) {
        Role role = gameEvent.role;
        if (role.getRes().guild.checkGuild().ok() && role.getRes().guild.performance.position >= GDGuild.position.VICE_PRESIDENT) {
            role.getRes().guild.getGuild().basic.presidentName = role.getBase().name;
            role.getRes().guild.getGuild().member.updateAllMemberData();
            role.getRes().guild.getGuild().member.getOnlineRole()
                    .stream()
                    .forEach(member -> member.getRes().guild.getGuild().noticeUpdate(member));
        }
    }
}
